package com.example.springbootplm.mapper;

import com.example.springbootplm.pojo.Emp;
import com.example.springbootplm.pojo.Emp1;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {


    //传统方法
    /*查询总记录数*/
    @Select("select count(*) from emp ")
    public Long count();

    /*传统分页查询*/
    @Select("select * from emp limit #{start},#{pageSize}")
    public List<Emp> page(@Param("start")Integer start, @Param("pageSize")Integer pageSize);

    // PageHelper分页插件
   /* @Select("select * from emp")
    public List<Emp> list( String name);*/

    //条件分页查询
   // @Select("select * from emp where name like concat('%',#{name},'%') and age = #{age} and entrydate between #{begin} and #{end}")
    //List<Emp> list(@Param("name")String name, @Param("age")Integer age, @Param("begin")LocalDate begin, @Param("end")LocalDate end);

    //批量删除

    //void delete(List<Integer> ids);

    //新增员工
   @Insert("insert into emp(name,age,job,salary,entrydate,dept_id) " +
            "values(#{name},#{age},#{job},#{salary},#{entrydate},#{deptId})")
    void insert(Emp emp);

//    员工登录操作
@Select("select * from emp where username = #{name} and password = #{password}")
Emp1 getByNameAndPassword(Emp1 emp1);











}
